﻿<UserControl x:Class="VastParkIDPlugin.PluginUI"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:vpid="clr-namespace:VastPark.ID.Design;assembly=VastPark.ID.Design"
             xmlns:mfdesign="clr-namespace:Metaforik.Design.Converters;assembly=Metaforik.Design"
             xmlns:vpdesign="clr-namespace:VastPark.Design;assembly=VastPark.Design"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300"
             Height="300"
             x:Name="This"
             Loaded="This_Loaded">
    <UserControl.Resources>
		<ResourceDictionary>
			<ResourceDictionary.MergedDictionaries>
				<ResourceDictionary Source="pack://application:,,,/VastPark.Design;component/Themes/generic.xaml" />
                <ResourceDictionary>
                    <mfdesign:MetaforikTypeConverter x:Key="_MetaforikTypeConverter" UseLargeImages="False"/>

                    <ContextMenu x:Key="_ContextMenu">
                        <MenuItem Header="Copy Link" Click="CopyLink_Click"/>
                    </ContextMenu>
                    <DataTemplate x:Key="_ResultsTemplate">
                        <Grid ContextMenu="{StaticResource _ContextMenu}">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="24" />
                                <ColumnDefinition />
                            </Grid.ColumnDefinitions>
                            <Image Source="{Binding Path=Assets[0].Type, Converter={StaticResource _MetaforikTypeConverter}}" HorizontalAlignment="Center" Stretch="None" />
                            <TextBlock Grid.Column="1" Text="{Binding Path=Name}" />
                        </Grid>
                    </DataTemplate>
                </ResourceDictionary>
            </ResourceDictionary.MergedDictionaries>
		</ResourceDictionary>		        
    </UserControl.Resources>
    <Grid Margin="5">
        <Grid x:Name="_LoggedInView">
            <Grid.RowDefinitions>
                <RowDefinition Height="28"/>
                <RowDefinition />
                <RowDefinition Height="28"/>
            </Grid.RowDefinitions>
            
            <vpdesign:InfoTextBox x:Name="_SearchBox" KeyUp="_SearchBox_KeyUp" IsEnabled="False" TextBoxInfo="Search"/>
            
            <Grid Grid.Row="1">
                <Grid.RowDefinitions>
                    <RowDefinition />
                    <RowDefinition Height="24"/>
                </Grid.RowDefinitions>
                <ListBox 
                    x:Name="_ResultsList"                
                    MouseDoubleClick="_ResultsList_MouseDoubleClick"
                    ItemsSource="{Binding ElementName=This, Path=Results}" 
                    ItemTemplate="{StaticResource _ResultsTemplate}"/>
                
                <StackPanel Orientation="Horizontal" Grid.Row="1" HorizontalAlignment="Right" Margin="5" x:Name="_ResultsCountText" Visibility="Collapsed">
                    <TextBlock Text="{Binding ElementName=This, Path=Results.Count}" />
                    <TextBlock Text=" result(s)" />
                </StackPanel>     
                
                <TextBlock Text="Searching..." Grid.Row="1" x:Name="_SearchingText" HorizontalAlignment="Right" Margin="5" Visibility="Collapsed"/>
            </Grid>
            
            <TextBlock x:Name="_NotLoggedIn" Grid.Row="2" HorizontalAlignment="Center" Margin="5">Not logged in. 
                <Hyperlink Click="Button_Click">Click here</Hyperlink>
            </TextBlock>
            
            <TextBlock x:Name="_LoggingIn" Grid.Row="2" HorizontalAlignment="Center" Margin="5" Visibility="Collapsed">
                Logging in, please wait...
            </TextBlock>
            
            <TextBlock x:Name="_LoggedIn" Grid.Row="2" HorizontalAlignment="Center" Margin="5" Visibility="Collapsed">Logged in as 
                <Hyperlink  Click="Button_Click">
                    <InlineUIContainer>
                        <TextBlock FontFamily="Arial" Text="{Binding Profile.Alias, ElementName=This}" TextTrimming="CharacterEllipsis" />
                    </InlineUIContainer>
                </Hyperlink>
            </TextBlock>
            <!--<Button Grid.Row="2" Content="Login" Click="Button_Click" Width="75" Height="23" />-->
        </Grid>
        <!--<Grid x:Name="_NotLoggedInView">
            <vpid:CreateAccount />
        </Grid>-->
    </Grid>
</UserControl>
